package cn.classyex.business.hr.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import cn.classyex.business.hr.domain.AdjustSalary;
import cn.classyex.business.hr.service.IAdjustSalaryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调薪记录管理Controller
 * 
 * @author yex
 * @date 2021-05-06
 */
@Controller
@RequestMapping("/hr/adjustSalary")
public class AdjustSalaryController extends BaseController
{
    private String prefix = "hr/adjustSalary";

    @Autowired
    private IAdjustSalaryService adjustSalaryService;

    @RequiresPermissions("hr:adjustSalary:view")
    @GetMapping()
    public String adjustSalary()
    {
        return prefix + "/adjustSalary";
    }

    /**
     * 查询调薪记录管理列表
     */
    @RequiresPermissions("hr:adjustSalary:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AdjustSalary adjustSalary)
    {
        startPage();
        List<AdjustSalary> list = adjustSalaryService.selectAdjustSalaryList(adjustSalary);
        return getDataTable(list);
    }

    /**
     * 导出调薪记录管理列表
     */
    @RequiresPermissions("hr:adjustSalary:export")
    @Log(title = "调薪记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AdjustSalary adjustSalary)
    {
        List<AdjustSalary> list = adjustSalaryService.selectAdjustSalaryList(adjustSalary);
        ExcelUtil<AdjustSalary> util = new ExcelUtil<AdjustSalary>(AdjustSalary.class);
        return util.exportExcel(list, "调薪记录管理数据");
    }

    /**
     * 新增调薪记录管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存调薪记录管理
     */
    @RequiresPermissions("hr:adjustSalary:add")
    @Log(title = "调薪记录管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AdjustSalary adjustSalary)
    {
        return toAjax(adjustSalaryService.insertAdjustSalary(adjustSalary));
    }

    /**
     * 修改调薪记录管理
     */
    @GetMapping("/edit/{adjustSalaryId}")
    public String edit(@PathVariable("adjustSalaryId") Long adjustSalaryId, ModelMap mmap)
    {
        AdjustSalary adjustSalary = adjustSalaryService.selectAdjustSalaryById(adjustSalaryId);
        mmap.put("adjustSalary", adjustSalary);
        return prefix + "/edit";
    }

    /**
     * 修改保存调薪记录管理
     */
    @RequiresPermissions("hr:adjustSalary:edit")
    @Log(title = "调薪记录管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AdjustSalary adjustSalary)
    {
        return toAjax(adjustSalaryService.updateAdjustSalary(adjustSalary));
    }

    /**
     * 删除调薪记录管理
     */
    @RequiresPermissions("hr:adjustSalary:remove")
    @Log(title = "调薪记录管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(adjustSalaryService.deleteAdjustSalaryByIds(ids));
    }
}
